<?php
//**************************************************************************
//
//            (C) Okulov Rostislav, 2011
//
//**************************************************************************

/*
 ***************************************************************************
 *                                                                         *
 *   This source is free software; you can redistribute it and/or modify   *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This code is distributed in the hope that it will be useful, but      *
 *   WITHOUT ANY WARRANTY; without even the implied warranty of            *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU     *
 *   General Public License for more details.                              *
 *                                                                         *
 *   A copy of the GNU General Public License is available on the World    *
 *   Wide Web at <http://www.gnu.org/copyleft/gpl.html>. You can also      *
 *   obtain it by writing to the Free Software Foundation,                 *
 *   Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.        *
 *                                                                         *
 */
  /* 
   * Delete ckecked line from list.
   *
   */
  include ('mysql_connect.php');

   $link = mysql_connect($dbhost, $dbuser, $dbpassword);
   if (empty($link)) {
      echo 'Не удалось подключиться к MySQL'; 
      exit;
   }
   mysql_select_db($dbname, $link);



   $query = "DELETE FROM httplink WHERE name='".mysql_escape_string($_GET['favpath'])."'";
   $result = mysql_query($query, $link);
   if (0 == $_GET['c']) {
      $query = "SELECT name FROM httplink GROUP BY domain HAVING count(domain) = 1";
      $result = mysql_query($query, $link);
      while ($line = mysql_fetch_row($result)) {
 
            echo '<option>'.$line[0].'</option>';
      }
   } 
   else {
      $query = "SELECT name FROM httplink WHERE domain LIKE '%".htmlspecialchars(parse_url(trim($_GET['favpath']), PHP_URL_HOST))."%'";
      $result = mysql_query($query, $link);
      while ($line = mysql_fetch_row($result)) {

            echo '<option>'.$line[0].'</option>';

      }
   }
      
   echo '|'.$_GET['c']; //add splitter | to split ajax string
?>
